//
//  AppData.m
//  HibuSearch
//
//  Created by Bruce_Li_799 on 6/10/13.
//  Copyright (c) 2013 HIBU. All rights reserved.
//

#import "AppData.h"
#import "AppHelper.h"

@interface AppData ()
{
    // use to indicator how many time use launch the app
    NSInteger _countOfAppLaunch;
}

- (NSString*) appLaunchKey;

@end

@implementation AppData

@synthesize countOfAppLaunch = _countOfAppLaunch;

-(id) init{
	self = [super init];
	if(self != nil){
        
        _countOfAppLaunch = 0;
	}
	return self;
}

- (NSString*) appLaunchKey
{
    return [NSString stringWithFormat:@"version_%@", [AppHelper appVersion]];
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeInteger:_countOfAppLaunch forKey:[self appLaunchKey]];
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    
    if (self) {
                
        _countOfAppLaunch = [aDecoder decodeIntegerForKey:[self appLaunchKey]];
//        NSLog(@"%d",_countOfAppLaunch);
    }
    return self;
}

@end
